package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OrgCqJk;
import com.ruoyi.system.service.IOrgCqJkService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务单元对应表Controller
 * 
 * @author ruoyi
 * @date 2025-09-09
 */
@Controller
@RequestMapping("/system/orgCqJk")
public class OrgCqJkController extends BaseController
{
    private String prefix = "system/orgCqJk";

    @Autowired
    private IOrgCqJkService orgCqJkService;

    @RequiresPermissions("system:orgCqJk:view")
    @GetMapping()
    public String orgCqJk()
    {
        return prefix + "/orgCqJk";
    }

    /**
     * 查询业务单元对应表列表
     */
    @RequiresPermissions("system:orgCqJk:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OrgCqJk orgCqJk)
    {
        startPage();
        List<OrgCqJk> list = orgCqJkService.selectOrgCqJkList(orgCqJk);
        return getDataTable(list);
    }

    /**
     * 导出业务单元对应表列表
     */
    @RequiresPermissions("system:orgCqJk:export")
    @Log(title = "业务单元对应表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OrgCqJk orgCqJk)
    {
        List<OrgCqJk> list = orgCqJkService.selectOrgCqJkList(orgCqJk);
        ExcelUtil<OrgCqJk> util = new ExcelUtil<OrgCqJk>(OrgCqJk.class);
        return util.exportExcel(list, "业务单元对应表数据");
    }

    /**
     * 新增业务单元对应表
     */
    @RequiresPermissions("system:orgCqJk:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存业务单元对应表
     */
    @RequiresPermissions("system:orgCqJk:add")
    @Log(title = "业务单元对应表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OrgCqJk orgCqJk)
    {
        return toAjax(orgCqJkService.insertOrgCqJk(orgCqJk));
    }

    /**
     * 修改业务单元对应表
     */
    @RequiresPermissions("system:orgCqJk:edit")
    @GetMapping("/edit/{code}")
    public String edit(@PathVariable("code") String code, ModelMap mmap)
    {
        OrgCqJk orgCqJk = orgCqJkService.selectOrgCqJkByCode(code);
        mmap.put("orgCqJk", orgCqJk);
        return prefix + "/edit";
    }

    /**
     * 修改保存业务单元对应表
     */
    @RequiresPermissions("system:orgCqJk:edit")
    @Log(title = "业务单元对应表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OrgCqJk orgCqJk)
    {
        return toAjax(orgCqJkService.updateOrgCqJk(orgCqJk));
    }

    /**
     * 删除业务单元对应表
     */
    @RequiresPermissions("system:orgCqJk:remove")
    @Log(title = "业务单元对应表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(orgCqJkService.deleteOrgCqJkByCodes(ids));
    }
}
